﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.BLL;
using Automobile.service.Model;
using System.Data;

namespace Automobile.service.UI
{
    public partial class VIPEdit : System.Web.UI.Page
    {
        MemberCardBLL bll = new MemberCardBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["id"].ToString() != null)
                {
                    LoadvipEdit();
                }
            }
        }
        public void LoadvipEdit()
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            DataTable table = bll.GetMemberById(id);
            this.MemberCard_Name.Value = table.Rows[0][1].ToString();
            this.MemberCard_owner.Value = table.Rows[0][2].ToString();
            this.MemberCard_Cnum.Value = table.Rows[0][3].ToString();
            this.MemberCard_CardID.Value = table.Rows[0][4].ToString();
            this.MemberCard_ingeral.Value = table.Rows[0][5].ToString();
            this.MemberCard_sphere.Value = table.Rows[0][6].ToString();
            this.Rank_Name.Value = table.Rows[0][7].ToString();
            this.MemberCard_State.Value = table.Rows[0][8].ToString();
        }

        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            MemberCard m = new MemberCard();
            m.MemberCard_Id = Convert.ToInt32(Request.QueryString["id"]);
            m.MemberCard_Name = this.MemberCard_Name.Value;
            m.MemberCard_owner = this.MemberCard_owner.Value;
            m.MemberCard_Cnum = this.MemberCard_Cnum.Value;
            m.MemberCard_CardID = this.MemberCard_CardID.Value;
            m.MemberCard_ingeral = Convert.ToInt32(MemberCard_ingeral.Value);
            m.MemberCard_sphere = Convert.ToDecimal(MemberCard_sphere.Value);
            m.Rank_Name = this.Rank_Name.Value;
            m.MemberCard_State = Convert.ToInt32(MemberCard_State.Value);
            if (bll.Upd(m) > 0)
            {
                Console.WriteLine("<script>alert('修改成功！');</script>");
                Response.Redirect("VIPShow.aspx");
            }
            else
            {
                Response.Write("<script>alert('修改！')");
            }
        }
    }
}